<?php
namespace PsiFramework\Classes\Util\Database\Query;

import("Classes.Util.Database.Query.SqlParameter");

use \PsiFramework\Classes\Util\Database\Query\SqlParameter;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The SqlFunction class is a SqlParameter which
 * allows to represent a sql function
 *
 * @package classes.util.xpersist.sql
 */
class SqlFunction extends SqlParameter
{

    protected /*string*/   $_name ;
    protected /*array*/    $_parameters ;
    protected /*string*/   $_alias = null ;

    /**
     * SqlFunction constructor
     *
     * @param $name        the name of the function
     * @param $parameters  the array of parameters
     *                     (SqlParameter) of the function
     */
    public function __construct(
        $name, 
        $parameters = array(),
        /*string*/ $alias=null
    )
    {
        $this->_name = $name ;
        $this->_parameters = $parameters ;
        $this->_alias = $alias ;
    }

    /**
     * This function allows to add a parameter to the sql function
     *
     * @param $parameter    the SqlParameter to add
     */
    public function addParameter(SqlParameter $parameter)
    {
        $this->_parameters[] = $parameter ;
    }

    /**
     * Getter for the member variable $name
     *
     * @return string
     */
    public function getName()
    {
        return $this->_name ;
    }

    /**
     * Getter for the member variable $parameters
     *
     * @return array of SqlParameters
     */
    public function getParameters()
    {
        return $this->_parameters ;
    }

    /**
     * Setter for the member variable $alias
     *
     * @param $alias
     */
    public function setAlias(/*string*/ $alias)
    {
        $this->_alias = $alias ;
    }

    /**
     * Getter for the member variable $alias
     *
     * @return string
     */
    public function getAlias()
    {
        return $this->_alias ;
    }

}

